package com.etoak.car.service;

import com.etoak.car.bean.Users;
import com.etoak.car.mapper.UserMassageMapper;
import com.etoak.commons.page.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserMassageService {

    @Autowired
    UserMassageMapper userMassageMapper;

    public Page<Users> querySome(int pageNum,int pageSize,String realname) {
        //设置分页条件
        PageHelper.startPage(pageNum,pageSize);
        //查询功能
        List<Users> users = userMassageMapper.querySome(realname);
        //创建pageInfo
        PageInfo<Users> pageInfo = new PageInfo<>(users);

        //返回结果
        return new Page<>(pageInfo.getPageNum(),
                pageInfo.getPageSize(),
                pageInfo.getTotal(),
                users,
                pageInfo.getPages());


    }

    public int delUser(int id) {
        return userMassageMapper.delUser(id);
    }

    public int updateVip(Users users) {
        return userMassageMapper.updateVip(users);
    }
    //根据id查询users
    public Users getById(int id) {
        return userMassageMapper.getById(id);
    }

    public int addMoney(Users users) {
        return userMassageMapper.addMoney(users);
    }
}
